<?php

class Core_Backend_Component_Customer_View_Shop_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('customer/index/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.submit'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'submit') . "')");
        $group->addButton($this->__('share.button.apply'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'apply') . "')");
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'save') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('shop_form')
                ->addHiddenField('id', 'shop[id]')
                ->addHiddenField('poi_id', 'shop[poi_id]', $this->getPoi()->getId());
        $form->addTextboxField($this->__('poi.label.signmap_name'), 'signmap_name', 'shop[signmap_name]');
        $form->addTextboxField($this->__('share.label.tag'), 'tag', 'shop[tag]');
        $form->addTextboxField($this->__('customer.label.ebook_url'), 'ebook_url', 'shop[ebook_url]');
        $form->addTextboxField($this->__('customer.label.url_name'), 'url_name', 'shop[url_name]');
        $form->addTextboxField($this->__('customer.label.location_id'), 'location_id', 'shop[location_id]');
        $form->addFileBrowserField($this->__('poi.label.signmap_picture'), 'signmap_picture', 'shop[signmap_picture]')
                ->setPath('pub/media/road/' . $this->getPoi()->getRoadId() . '/' . $this->getPoi()->getId() . '/signmap')
                ->setFileType('image')
                ->setCallback('selectSignMapPicture');
        $form->addTextareaField($this->__('share.label.introduction'), 'introduction', 'shop[introduction]');
        $form->addEditorField($this->__('share.label.detail'), 'detail', 'shop[detail]');
        $form->createTab('base_option', $this->__('customer.label.base_information'), array('field_signmap_name','field_tag','field_tag','field_ebook_url','field_url_name','field_location_id','field_signmap_picture','field_introduction'));
        $form->createTab('content_option', $this->__('customer.label.detailed_information'), array('field_detail'));
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}